/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-06-28 02:01:44
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.audit.entity;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_audit_log_record_his")
@SQLDelete(sql = "update wwyt_audit_log_record_his set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_audit_log_record_his set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
public class AuditLogRecordHis implements java.io.Serializable {

    // columns START
    @Id
    @GeneratedValue(strategy = IDENTITY)

    // ID
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    // 编号
    @Column(name = "CODE", length = 10)
    private String code;

    // 行为ID
    @Column(name = "ACTION_DEF_ID")
    private Long actionDefId;

    // 用户ID
    @Column(name = "USER_ID")
    private Long userId;

    // 用户姓名
    @Column(name = "USER_NAME", length = 12)
    private String userName;

    // 模块
    @Column(name = "MODULE", length = 30)
    private String module;

    // 操作名称
    @Column(name = "OPERATION_NAME", length = 50)
    private String operationName;

    // 发生时间
    @Column(name = "HAPPEN_TIME")
    private java.util.Date happenTime;

    // IP地址
    @Column(name = "IP", length = 15)
    private String ip;

    // MAC地址
    @Column(name = "MAC", length = 17)
    private String mac;

    // 操作结果
    @Column(name = "RESULT")
    private Byte result;

    // 操作对象类型
    @Column(name = "OP_OBJECT_TYPE", length = 100)
    private String opObjectType;

    // 操作对象值
    @Column(name = "OP_OBJECT_VALUE", length = 200)
    private String opObjectValue;

    // 描述
    @Column(name = "DESCRIPTION", length = 300)
    private String description;

    // 创建人
    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    private Long createBy;

    // 创建时间
    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    private java.util.Date createTime;

    // 更新人
    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    private Long updateBy;

    // 更新时间
    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    private java.util.Date updateTime;

    // 删除标记
    @Column(name = "DELETE_FLAG", length = 2)
    private String deleteFlag;
    // columns END
    @Column(name = "ORG_CODE", length = 100)
    private String orgCode;
    @Column(name = "TENENT_ID")
    private Long tenentId;

    public int hashCode() {
        return new HashCodeBuilder()
                .append(getId())
                .toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof AuditLogRecordHis == false)
            return false;
        if (this == obj)
            return true;
        AuditLogRecordHis other = (AuditLogRecordHis) obj;
        return new EqualsBuilder()
                .append(getId(), other.getId())
                .isEquals();
    }
}
